﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Utils
{
    public static class Extensions
    {
        public static string BuildErrorString(this Exception e)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendFormat("{0} causing the error: {1}\n", e.Source, e.Message);
            if (e.InnerException != null)
                sb.AppendFormat("Inner exception: {0}\n", e.InnerException.Message);
            sb.AppendFormat("Stack trace: {0}", e.StackTrace);

            return sb.ToString();
        }
    }
}
